﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System.Windows.Input;

namespace Xceed.Silverlight.ListBox
{
  internal class NavigationInfo
  {
    private NavigationInfo( Key key,
        bool forwardScrolling,
        bool isCtrlDown,
        bool pageScrolling )
    {
      this.Key = key;
      this.IsForwardScrolling = forwardScrolling;
      this.IsPageScrolling = pageScrolling;
      this.IsCtrlDown = isCtrlDown;
    }

    public Key Key
    {
      get;
      private set;
    }

    public bool IsCtrlDown
    {
      get;
      private set;
    }

    public bool IsForwardScrolling
    {
      get;
      private set;
    }

    public bool IsPageScrolling
    {
      get;
      private set;
    }

    public bool ForcedBringIntoView
    {
      get;
      set;
    }

    public static NavigationInfo GetNavigationInfoFromKey( Key key )
    {
      bool isForwardScrolling = false;
      bool isPageScrolling = false;

      bool isCtrlDown = ( ( Keyboard.Modifiers & ModifierKeys.Control ) == ModifierKeys.Control );

      switch( key )
      {
        case Key.Down:
          isForwardScrolling = true;
          break;

        case Key.Up:
          break;

        case Key.Right:
          isForwardScrolling = true;
          break;

        case Key.Left:
          break;

        case Key.PageDown:
          isForwardScrolling = true;
          isPageScrolling = true;
          break;

        case Key.PageUp:
          isPageScrolling = true;
          break;

        case Key.End:
          isForwardScrolling = true;
          break;

        case Key.Home:
          break;
      }

      return new NavigationInfo( key,
        isForwardScrolling,
        isCtrlDown,
        isPageScrolling );
    }
  }
}
